﻿@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_Index.cshtml";
}

<script>
    $(function () {
        gridList();
    })
    function gridList() {
        var $gridList = $("#gridList");
        $gridList.dataGrid({
            url: "/WorkflowManage/Workflownodeoperator/GetGridJson",
            height: $(window).height() - 126,
            colModel: [
                { label: "主键", name: "id", hidden: true, key: true },
                {
                    label: '节点动作', name: 'nodeactionid', width: 150, align: 'left',
                    formatter: function (cellvalue) {
                        $.ajax({
                            url: "/WorkflowManage/Workflownodeoperator/GetSelectNaJson",
                            data: { keyValue: cellvalue },
                            dataType: "json",
                            async: false,
                            success: function (data) {
                                cellvalue = data[0].text;
                            }
                        });
                        return cellvalue;
                    }
                },
                {
                    label: '操作者', name: 'nodeoperator', width: 150, align: 'left',
                    formatter: function (cellvalue) {
                        $.ajax({
                            url: "/WorkflowManage/Workflownodeoperator/GetSelectUserJson",
                            data: { keyValue: cellvalue },
                            dataType: "json",
                            async: false,
                            success: function (data) {
                                cellvalue = data[0].text;
                            }
                        });
                        return cellvalue;
                    }
                },
                {
                    label: '操作者类型', name: 'operatortype', width: 150, align: 'left',
                    formatter: function (cellvalue) {
                        switch (cellvalue) {
                            case 1:
                                cellvalue = "角色";
                                break;
                            case 2:
                                cellvalue = "用户";
                                break;
                            default:
                                cellvalue = "其它";
                                break;
                        }
                        return cellvalue;
                    }
                },
                { label: '开始时间', name: 'begintime', width: 150, align: 'left' },
                { label: '结束时间', name: 'endtime', width: 150, align: 'left' },
                {
                    label: '操作状态', name: 'operatorstatus', width: 150, align: 'left',
                    formatter: function (cellvalue) {
                        return cellvalue == 1 ? "启用" : "未启用";
                    }
                },
                {
                    label: '操作锁定状态', name: 'operatorlock', width: 150, align: 'left',
                    formatter: function (cellvalue) {
                        return cellvalue == 1 ? "锁定" : "未锁定";
                    }
                }
                
            ],
            pager: "#gridPager",
            sortname: 'id asc',
            viewrecords: true
        });
        $("#btn_search").click(function () {
            $gridList.jqGrid('setGridParam', {
                postData: { keyword: $("#txt_keyword").val() },
            }).trigger('reloadGrid');
        });
    }
    function btn_add() {
        $.modalOpen({
            id: "Form",
            title: "新增角色",
            url: "/WorkflowManage/Workflownodeoperator/Form",
            width: "700px",
            height: "510px",
            callBack: function (iframeId) {
                top.frames[iframeId].submitForm();
            }
        });
    }
    function btn_edit() {
        var keyValue = $("#gridList").jqGridRowValue().id;
        $.modalOpen({
            id: "Form",
            title: "修改角色",
            url: "/WorkflowManage/Workflownodeoperator/Form?keyValue=" + keyValue,
            width: "700px",
            height: "510px",
            callBack: function (iframeId) {
                top.frames[iframeId].submitForm();
            }
        });
    }
    function btn_delete() {
        $.deleteForm({
            url: "/WorkflowManage/Workflownodeoperator/DeleteForm",
            param: { keyValue: $("#gridList").jqGridRowValue().id },
            success: function () {
                $.currentWindow().$("#gridList").trigger("reloadGrid");
            }
        })
    }
    function btn_details() {
        var keyValue = $("#gridList").jqGridRowValue().id;
        $.modalOpen({
            id: "Details",
            title: "查看角色",
            url: "/WorkflowManage/Workflownodeoperator/Details?keyValue=" + keyValue,
            width: "700px",
            height: "510px",
            btn: null,
        });
    }
    function btn_copyandpaste() {
        $.deleteForm({
            url: "/WorkflowManage/Workflownodeoperator/copyAndPasteForm",
            param: { keyValue: $("#gridList").jqGridRowValue().id },
            success: function () {
                $.currentWindow().$("#gridList").trigger("reloadGrid");
            }
        })
    }
</script>
<div class="topPanel">
    <div class="toolbar">
        <div class="btn-group">
            <a class="btn btn-primary" onclick="$.reload()"><span class="glyphicon glyphicon-refresh"></span></a>
        </div>
        <div class="btn-group">
        <a id="NF-add" authorize="yes" class="btn btn-primary dropdown-text" onclick="btn_add()"><i class="fa fa-plus"></i>新建节点操作者</a>
        </div>
        <div class="operate">
            <ul class="nav nav-pills">@*authorize="yes"*@
                <li class="first">已选中<span>1</span>项</li>
                <li><a id="NF-edit"  authorize="yes" onclick="btn_edit()"><i class="fa fa-pencil-square-o"></i>修改节点操作者</a></li>
                <li><a id="NF-delete" authorize="yes" onclick="btn_delete()"><i class="fa fa-trash-o"></i>删除节点操作者</a></li>
                <li><a id="NF-Details" authorize="yes" onclick="btn_details()"><i class="fa fa-search-plus"></i>查看节点操作者</a></li>
                <li><a id="NF-copyAndPaste"  onclick="btn_copyandpaste()"><i class="fa fa-search-plus"></i>复制节点操作者</a></li>
            </ul>
            <a href="javascript:;" class="close"></a> 
        </div>
        @*<script>$('.toolbar').authorizeButton()</script>*@
    </div>
    <div class="search">
        <table>
            <tr>
                <td>
                    <div class="input-group">
                        <input id="txt_keyword" type="text" class="form-control" placeholder="节点操作者名称" style="width: 200px;">
                        <span class="input-group-btn">
                            <button id="btn_search" type="button" class="btn  btn-primary"><i class="fa fa-search"></i></button>
                        </span>
                    </div>
                </td>
            </tr>
        </table>
    </div>
</div>
<div class="gridPanel">
    <table id="gridList"></table>
    <div id="gridPager"></div>
</div>

